<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of projectPersonnel
 *
 * @author nstevens
 */
class projectPersonnel {
    
    public $personID, $name, $phone, $email, $address, $company, $role;
    
    public function __construct($row, $username=NULL) {
        if($username){
            $row = $this->initSingleUser($username);
        }        
        $this->personID = $row['personID'];
        $this->address = getFieldGivenAnID("person", "personID", $this->personID, "address");
        $this->company = getFieldGivenAnID("person", "personID", $this->personID, "company");
        $this->email = getFieldGivenAnID("person", "personID", $this->personID, "email");
        $this->name = getFieldGivenAnID("person", "personID", $this->personID, "name");
        $this->phone = getFieldGivenAnID("person", "personID", $this->personID, "phone");
        $this->role = $row['role'];
    }
    
    private function initSingleUser($username){
        $ppSelect = "SELECT p.*, u.role FROM person p, user u WHERE p.personID=u.personID AND u.username='$username'";
        $ppResult = executeSelect($ppSelect);
        return mysqli_fetch_array($ppResult);
    }
}

?>
